package com.example.expandableview.slice;

import org.junit.Test;

import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;

public class MainAbilitySliceTest {
    private Class unitClass;
    private Object obj;

    /**
     * 初始化被测试类
     */
    private void initClass() {
        try {
            unitClass = Class.forName("com.example.expandableview.slice.MainAbilitySlice");
            obj = unitClass.getConstructor().newInstance();   //实例化一个对象
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        } catch (IllegalAccessException e) {
            e.printStackTrace();
        } catch (InstantiationException e) {
            e.printStackTrace();
        } catch (InvocationTargetException e) {
            e.printStackTrace();
        } catch (NoSuchMethodException e) {
            e.printStackTrace();
        }
    }

    /**
     * 创建顶部的折叠view
     */
    @Test
    public void createTopExpandableView() {
        initClass();
        try {
            Method method = unitClass.getMethod("createTopExpandableView", Object.class);
            method.invoke(obj, new Object[]{});
        } catch (NoSuchMethodException e) {
            e.printStackTrace();
        } catch (IllegalAccessException e) {
            e.printStackTrace();
        } catch (InvocationTargetException e) {
            e.printStackTrace();
        }
    }


    /**
     * 创建中间的折叠view
     */
    @Test
    public void createMiddleExpandableView() {
        initClass();
        try {
            Method method = unitClass.getMethod("createMiddleExpandableView", Object.class);
            method.invoke(obj, new Object[]{});
        } catch (NoSuchMethodException e) {
            e.printStackTrace();
        } catch (IllegalAccessException e) {
            e.printStackTrace();
        } catch (InvocationTargetException e) {
            e.printStackTrace();
        }
    }

    /**
     * 创建内部的折叠view
     */
    @Test
    public void createInnerExpandableViewLevel() {
        initClass();
        try {
            Method method = unitClass.getMethod("createInnerExpandableViewLevel", Object.class);
            method.invoke(obj, new Object[]{});
        } catch (NoSuchMethodException e) {
            e.printStackTrace();
        } catch (IllegalAccessException e) {
            e.printStackTrace();
        } catch (InvocationTargetException e) {
            e.printStackTrace();
        }
    }
}